package io.github.wangtisnruipopo.carscore.utils;

import io.github.wangtisnruipopo.carscore.enums.CardValueEnum;
import io.github.wangtisnruipopo.carscore.types.IValue;

import java.util.List;

public class CompareUtil {
    public static <V extends IValue<X>, X> int compareTo(V v1, V v2, List<X> list) {
        if (v1.getValue() == v2.getValue()) return 0;
        // 查找集合中所在位置
        int a = 0;
        int b = 0;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i) == v1.getValue()) {
                a = i;
                continue;
            }
            if (list.get(i) == v2.getValue()) {
                b = i;
            }
        }
        return a - b;
    }
}
